package com.yeyks.controller.activity;

import com.yeyks.account.dal.domain.AccountInfo;
import com.yeyks.annotation.NeedToken;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.base.Arguments;
import com.yeyks.common.base.PageResult;
import com.yeyks.common.em.accountinfo.AccountInfoTypeEnum;
import com.yeyks.common.param.PageParam;
import com.yeyks.other.dal.domain.ActivityDrawRecord;
import com.yeyks.other.service.ActivityDrawRecordService;
import com.yeyks.web.AccountUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author fuchangshuai
 * @since 2019-07-03
 */
@Api(tags = "活动抽奖记录模块")
@RestController
@Slf4j
@RequestMapping(value = "/activity/draw/record")
public class ActivityDrawRecordController {
    @Autowired
    private ActivityDrawRecordService activityDrawRecordService;

    @NeedToken
    @ApiOperation(value = "活动抽奖记录模块 --> 列表", notes = "总公司权限", response = ActivityDrawRecord.class)
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public AjaxResponseBody<PageResult<ActivityDrawRecord>> list(PageParam page) {
        AccountInfo loginUser = AccountUtils.getLoginUser();
        Arguments.isTrue(!AccountInfoTypeEnum.Administrator.value().equals(loginUser.getType()), "您无权查看");
        PageResult<ActivityDrawRecord> pageResult = activityDrawRecordService.myList(page);
        return AjaxResponseBody.success(pageResult);
    }

}